var httpdetector = require('../../../monitor/detector/http');




describe('http 检查', function () {
  before(function () {
    // console.log('Pre something');
  });
  describe('GET 方式请求http://www.google.com/的URL', function () {
    it('5s超时', function (done) {
      httpdetector.detect({
        timeout: 5000,
        url: 'http://www.google.com/'
      },function(data){
        expect(data.timeout).toBeTruthy();
        expect(data.error).not.toBeNull();
        done();
      });
    });
  });

  describe('GET 方式请求https://www.baidu.com/的URL', function () {
    it('5s超时应该返回code :200', function (done) {
      httpdetector.detect({
        timeout: 5000,
        url: 'https://www.baidu.com/'
      },function(data){
        expect(data.timeout).not.toBeTruthy();
        
        expect(data.error).toBeUndefined();
        expect(data.result.code).toBe(200);
        done();
      });
    });
  });  

  after(function () {
    // console.log('Post something');
  });

});

















